package com.ruoyi.web.controller.match.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.match.dto.RegisterDto;
import com.ruoyi.match.service.AuthService;
import com.ruoyi.match.dto.LoginDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Author: 廖振辉
 * Date: 2022/4/27
 * Description:
 */
@Api(tags = "登录授权")
@RestController
@RequestMapping("/match")
public class AuthController {

    @Autowired
    private AuthService authService;

    @ApiOperation("登录")
    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginDto loginDto){
        String token = authService.login(loginDto);
        return AjaxResult.success("登陆成功",token);
    }

    @ApiOperation("注册")
    @PostMapping("register")
    public AjaxResult register(@RequestBody RegisterDto registerDto){
        authService.register(registerDto);
        return AjaxResult.success();
    }

}
